﻿<Application
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
	xmlns:converters="clr-namespace:Yelper.Phone.ValueConverters"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls" 
    xmlns:controlsPrimitives="clr-namespace:Microsoft.Phone.Controls.Primitives;assembly=Microsoft.Phone.Controls" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
	xmlns:navigation="clr-namespace:System.Windows.Navigation;assembly=Microsoft.Phone"
    mc:Ignorable="d" 
    x:Class="Yelper.Phone.App"
    >

    <!--Application Resources-->
    <Application.Resources>
    	<converters:YelpTimeAgoFormatter x:Key="YelpTimeAgoConverter" />
		<converters:ProfilePictureConverter x:Key="ProfilePictureConverter" />
		<converters:ToUpperConverter x:Key="ToUpperConverter" />
		<converters:AtToUpperConverter x:Key="AtToUpperConverter" />        
		
		<Color x:Key="ApplicationBarForegroundColor">White</Color>
    	<SolidColorBrush x:Key="ForegroundBrush" Color="#FFD0934D"/>
    	<Color x:Key="ApplicationBarBackgroundColor">#FFB27A3A</Color>
		
		<navigation:UriMapper x:Name="mapper"> 
    		<navigation:UriMapping Uri="/StartUp" MappedUri="/MainPage.xaml" />
            <navigation:UriMapping Uri="/Login" MappedUri="/Login.xaml" />
            <navigation:UriMapping Uri="/About" MappedUri="/About.xaml" />
            <navigation:UriMapping Uri="/NewYelp" MappedUri="/NewYelp.xaml" />
            <navigation:UriMapping Uri="/YelpDetail" MappedUri="/YelpDetail.xaml" />
            
        </navigation:UriMapper>
		
		<Style x:Key="HyperlinkButtonStyleWrapped" TargetType="HyperlinkButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="HyperlinkButton">
                    <Grid HorizontalAlignment="Left" VerticalAlignment="Top">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Disabled"/>
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver" />
                                <VisualState x:Name="Pressed"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <TextBlock x:Name="tbNormal" Margin="0" TextWrapping="Wrap" Text="{TemplateBinding Content}" d:LayoutOverrides="Width, Height" HorizontalAlignment="Left" VerticalAlignment="Top">
                        	<TextBlock.Foreground>
                        		<SolidColorBrush Color="{StaticResource ApplicationBarBackgroundColor}"/>
                        	</TextBlock.Foreground>
                        </TextBlock>                        
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>        
    </Style>
	
		<DataTemplate x:Key="TimelineDataTemplate">
			<Grid Margin="0,10,0,0" d:DesignWidth="148" d:DesignHeight="110">
    								<Grid.ColumnDefinitions>
    									<ColumnDefinition Width="Auto"/>
    									<ColumnDefinition Width="*"/>
    									<ColumnDefinition Width="Auto"/>
    								</Grid.ColumnDefinitions>
    								<Grid.RowDefinitions>
    									<RowDefinition Height="Auto" />
    									<RowDefinition Height="Auto" />
    								</Grid.RowDefinitions>
    								<Border Grid.RowSpan="2" Background="#FF7E7E7E" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,5,15,0">
    									<Image Source="{Binding User.ProfilePicture, Converter={StaticResource ProfilePictureConverter}, Mode=OneWay}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="50" Height="50"/>										
                    <!--<toolkit:GestureService.GestureListener>
                        <toolkit:GestureListener Tap="UserTap" />
                    </toolkit:GestureService.GestureListener>-->
                </Border>
                <TextBlock Text="{Binding User.Username}" HorizontalAlignment="Stretch" FontWeight="Bold" FontSize="24" VerticalAlignment="Top" d:LayoutOverrides="VerticalAlignment" Grid.Column="1">
                    <toolkit:GestureService.GestureListener> 
                        <toolkit:GestureListener Tap="YelpTap" /> 
                    </toolkit:GestureService.GestureListener>
                </TextBlock>
                <TextBlock Text="{Binding Message}" FontSize="18.667" TextWrapping="Wrap" VerticalAlignment="Top" Grid.Row="1" Grid.Column="1" Margin="0,-7,0,0" Grid.ColumnSpan="2">
                    <toolkit:GestureService.GestureListener> 
                        <toolkit:GestureListener Tap="YelpTap" /> 
                    </toolkit:GestureService.GestureListener>
                </TextBlock>
                <TextBlock Grid.Column="2" HorizontalAlignment="Right" Text="{Binding YelpDate, Converter={StaticResource YelpTimeAgoConverter}, Mode=OneWay}" Margin="0" VerticalAlignment="Top"/>
    		</Grid>			
		</DataTemplate>
		
    	<DataTemplate x:Key="PivotHeaderDataTemplate">
    		<Grid>
    			<TextBlock TextWrapping="Wrap" Text="{Binding}" d:LayoutOverrides="Width, Height" FontSize="48"/>
    		</Grid>
    	</DataTemplate>
        
    	<Style x:Key="PivotStyle" TargetType="controls:Pivot">
    		<Setter Property="Margin" Value="0"/>
    		<Setter Property="Padding" Value="0"/>
    		<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
    		<Setter Property="Background" Value="Transparent"/>
    		<Setter Property="ItemsPanel">
    			<Setter.Value>
    				<ItemsPanelTemplate>
    					<Grid/>
    				</ItemsPanelTemplate>
    			</Setter.Value>
    		</Setter>
    		<Setter Property="Template">
    			<Setter.Value>
    				<ControlTemplate TargetType="controls:Pivot">
    					<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
    						<Grid.RowDefinitions>
    							<RowDefinition Height="Auto"/>
    							<RowDefinition Height="Auto"/>
    							<RowDefinition Height="*"/>
    						</Grid.RowDefinitions>
    						<Grid Background="{TemplateBinding Background}" CacheMode="BitmapCache" Grid.RowSpan="3"/>
    						<ContentPresenter ContentTemplate="{TemplateBinding TitleTemplate}" Content="{TemplateBinding Title}" Margin="24,17,0,-7"/>
    						<controlsPrimitives:PivotHeadersControl x:Name="HeadersListElement" Grid.Row="1" Foreground="{StaticResource ForegroundBrush}"/>
    						<ItemsPresenter x:Name="PivotItemPresenter" Margin="{TemplateBinding Padding}" Grid.Row="2"/>
    					</Grid>
    				</ControlTemplate>
    			</Setter.Value>
    		</Setter>
    	</Style>
		
		
    	<Style x:Key="TimelineListBoxItemStyle" TargetType="ListBoxItem">
    		<Setter Property="Background" Value="Transparent"/>
    		<Setter Property="BorderThickness" Value="0"/>
    		<Setter Property="BorderBrush" Value="Transparent"/>
    		<Setter Property="Padding" Value="0"/>
    		<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    		<Setter Property="VerticalContentAlignment" Value="Top"/>
    		<Setter Property="Template">
    			<Setter.Value>
    				<ControlTemplate TargetType="ListBoxItem">    				
    					<Border x:Name="LayoutRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
    						<VisualStateManager.VisualStateGroups>
    							<VisualStateGroup x:Name="CommonStates">
    								<VisualState x:Name="Normal"/>
    								<VisualState x:Name="MouseOver"/>
    								<VisualState x:Name="Disabled">
    									<Storyboard>
    										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="LayoutRoot">
    											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TransparentBrush}"/>
    										</ObjectAnimationUsingKeyFrames>
    										<DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentContainer"/>
    									</Storyboard>
    								</VisualState>
    							</VisualStateGroup>
    							<VisualStateGroup x:Name="SelectionStates">
    								<VisualState x:Name="Unselected"/>
    								<VisualState x:Name="Selected"/>
    								<VisualState x:Name="SelectedUnfocused"/>
    							</VisualStateGroup>
    							<VisualStateGroup x:Name="LayoutStates">
    								<VisualState x:Name="AfterLoaded"/>
    								<VisualState x:Name="BeforeLoaded"/>
    								<VisualState x:Name="BeforeUnloaded"/>
    							</VisualStateGroup>
    							<VisualStateGroup x:Name="FocusStates">
    								<VisualState x:Name="Unfocused"/>
    								<VisualState x:Name="Focused"/>
    							</VisualStateGroup>
    						</VisualStateManager.VisualStateGroups>
    						<ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
    					</Border>
    				</ControlTemplate>
    			</Setter.Value>
    		</Setter>
    	</Style>
    </Application.Resources>

    <Application.ApplicationLifetimeObjects>
        <!--Required object that handles lifetime events for the application-->
    	<shell:PhoneApplicationService 
    		Launching="Application_Launching" Closing="Application_Closing" 
    		Activated="Application_Activated" Deactivated="Application_Deactivated"/>
    </Application.ApplicationLifetimeObjects>

</Application>